home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Muddweller 1.2 / source code / Externals / BigText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-11  |  3.8 KB  |  94 lines  |  [TEXT/MPS ]

  1. /* BigText - Supports large line-wrapped text buffers                         */
  2.  
  3. #ifndef __BIGTEXT__
  4. #define __BIGTEXT__
  5.  
  6.         // • MacApp
  7. #ifndef __UMacApp__
  8. #include "UMacApp.h"
  9. #endif
  10.  
  11.  
  12. const int kTBSize = 1000;    /* Size of buffer, should be << 32K */
  13. const short kLSChunk = kTBSize / 20;
  14. const short kMaxTBSize = 32766;
  15. const short kMaxChunk = 320; /* kMaxChunk * max char width must be < 32K! */
  16. const int kClikDelay = 3;    /* Delay in ticks for autoscrolling */
  17. const int kBTRsrv = 10000;    /* Size of memory reserve */
  18.  
  19. typedef short LineStarts [32767];
  20. typedef LineStarts *LSPtr, **LSHandle;
  21.  
  22. typedef struct TextBuffer *TBPtr, **TBHandle;
  23.  
  24. struct TextBuffer {
  25.     TBHandle bNext;            /* Handle to next buffer */
  26.     short bLength;            /* Number of chars in this buffer */
  27.     short bLines;            /* Number of lines in this buffer */
  28.     long bVersion;            /* Format version of this buffer */
  29.     LSHandle bStarts;        /* Line start array */
  30.     unsigned char bBuf [kTBSize]; /* Text stored in this buffer */
  31. };
  32.  
  33.  
  34. class TBigText: public TObject {
  35. public:
  36.     TBHandle fText;            /* The first text buffer */
  37.     VRect fBounds;            /* Keeps track of text width and offsets */
  38.     Rect fDisplay;            /* The visible part of the text */
  39.     long fCurVers;            /* Current format version */
  40.     TextStyle fStyle;        /* Our text style */
  41.     long fLineHeight;        /* Height of a line in pixels */
  42.     long fTabWidth;            /* Width of a tab in pixels */
  43.     long fSelStart;            /* Start of the selection */
  44.     long fSelEnd;            /* End of the selection */
  45.     long fLength;            /* Length of the text */
  46.     long fMaxLength;        /* Maximum allowed length of the text */
  47.     long fMaxLowSize;        /* Maximum size during low memory situation */
  48.     Handle fMemReserve;        /* Memory reserve for the view */
  49.     Boolean fActive;        /* Is this text view active? */
  50.     Boolean fAutoWrap;        /* Wrap around text within view bounds? */
  51.     TView *fSuperView;        /* For ClikLoop, better solution ??? */
  52.     
  53.     virtual pascal void BTActivate (Boolean activate, Boolean redraw);
  54.     virtual pascal void BTAppend (unsigned char *buf, long count,
  55.         Boolean redraw);
  56.     virtual pascal void BTClick (Point *pt, short clicks, Boolean extend);
  57.     virtual pascal void BTDrop (long size, Boolean redraw);
  58.     virtual pascal Handle BTGetText (void);
  59.     virtual pascal void BTResize (Rect *display, long bleft, long bwidth,
  60.         Boolean redraw);
  61.     virtual pascal void BTScroll (long h, long v, Boolean redraw);
  62.     virtual pascal void BTSetSelect (long selStart, long selEnd,
  63.         Boolean redraw);
  64.     virtual pascal void BTSetStyle (TextStyle *theStyle, long tabChars,
  65.         Boolean redraw);
  66.     
  67.     virtual pascal TBHandle AppendBuf (TBHandle th, long size);
  68.     virtual pascal long AppendChars (unsigned char *buf, long count);
  69.     virtual pascal long Buf2Char (TBHandle th, long pos);
  70.     virtual pascal long Buf2Hor (TBHandle th, long pos);
  71.     virtual pascal long Buf2Vert (TBHandle th, long pos);
  72.     virtual pascal void BuildReserve (Boolean build);
  73.     virtual pascal void Char2Buf (long charPos, TBHandle *th, long *pos);
  74.     virtual pascal long ChunkSize (TBHandle th, long pos, long epos);
  75.     virtual pascal void ClrLines (TBHandle th);
  76.     virtual pascal void Draw (Rect *area);
  77.     virtual pascal void DropBuf (void);
  78.     virtual pascal Boolean DropSome (void);
  79.     virtual pascal long FindLine (TBHandle th, long pos);
  80.     virtual pascal void FindRun (short clicks, long h, long v, long *cbeg,
  81.         long *cend, long *cloc);
  82.     virtual pascal void Free (void);
  83.     virtual pascal void Highlight (long start, long end);
  84.     virtual pascal void Hor2Buf (long h, TBHandle th, long *pos, Boolean *left);
  85.     virtual pascal void IBigText (Rect *display, TextStyle *theStyle,
  86.         long tabChars, TView *itsView);
  87.     virtual pascal void Recalc (long vfrom, long vto, Boolean adjTop);
  88.     virtual pascal void RecalcBuf (TBHandle th);
  89.     virtual pascal Boolean SetLSVal (LSHandle lh, long line, short val);
  90.     virtual pascal void Vert2Buf (long v, TBHandle *th, long *pos);
  91. };
  92.  
  93. #endif
  94.